#include <iostream>
#include"../ser/server.hpp"

int main() 
{
    Socket cli_sock;
    cli_sock.CreateClient(8080,"127.0.0.1");
    std::string msg;
    while (1)
    {
        std::cout << "input message: ";
        std::cin >> msg;
        char buffer[1024];
        int len = cli_sock.Send(msg.c_str(), msg.size());
        if (len <= 0)
        {
            std::cout << "send failed" << std::endl;
            continue;
        }
        len = cli_sock.Recv(buffer, 1023);
        if (len <= 0)
        {
            std::cout << "recv failed" << std::endl;
            continue;
        }
        buffer[len] = '\0';
        std::cout << "recv message: " << buffer << std::endl;
        sleep(1);
    }
    cli_sock.Close();
    return 0;
}